//https://www.dotcpp.com/oj/contest6276_problem0.html
package 题目集.dfs;

import java.util.Scanner;

public class 移动射靶 {
    static int n;
    static int[] top;   //上方靶子的箭
    static int[] left;  //左方靶子的箭
    static int[][] dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    static int total;    //总步数
    static int[] path;
    static boolean[] vis = new boolean[20 * 20];

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        n = sc.nextInt();
        top = new int[n];
        left = new int[n];
        total =0;
        for (int i = 0; i < top.length; i++) {
            top[i] = sc.nextInt();
            total += top[i];
        }
        for (int i = 0; i < left.length; i++) {
            left[i] = sc.nextInt();
        }
        path = new int[total];
        dfs(0, 0, 0);
        for (int i : path) {
            System.out.println(i);
        }
    }

    public static boolean dfs(int step, int x, int y) {
        //越界，或者上方或左方靶子的箭数为0或者步数超过总步数
        if (x < 0 || x >= n || y < 0 || y >= n || top[y] == 0 || left[x] == 0 || step >= total) {
            return false;
        }
        path[step] = hash(x, y);
        if (vis[path[step]]) {
            return false;
        }
        if (step == total - 1) {
            return x+y==n*2-2;
        }
        top[y]--;
        left[x]--;
        vis[path[step]] = true;
        for (int[] d : dir) {
            int nx = x + d[0];
            int ny = y + d[1];
            if (dfs(step + 1, nx, ny)) {
                return true;
            }
        }
        top[y]++;
        left[x]++;
        vis[path[step]] = false;
        return false;
    }

    public static int hash(int x, int y) {
        return x * n + y;
    }
}
